<?php
namespace App\Admin\Renderable;

use App\Admin\Actions\Grid\CircleAction;
use App\Models\Circle\WxCircle;
use Dcat\Admin\Actions\Action;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class CircleRender extends LazyRenderable
{
    public function grid(): Grid
    {
        return Grid::make(new WxCircle(), function (Grid $grid) {
            global $__MINI_GLOBAL_TENANT_ID__;
            if($__MINI_GLOBAL_TENANT_ID__ > 0){
                $grid->model()->where('tenant_id', '=', $__MINI_GLOBAL_TENANT_ID__);
            }
            $grid->simplePaginate();
            $grid->model()->orderBy('id', 'desc');
            $grid->quickSearch(['id','circle_name', 'circle_introduce', 'wxUser.user_name'])->placeholder('搜索圈子ID,名称，介绍，'.env('circle_user_call', '圈主').'名字...')->width(35);
            $grid->column('id');
            $grid->column('circle_name');
            $grid->column('sort')->editable();
            $grid->column('circle_introduce')->sortable()->limit(9);
            $grid->column('head_portrait')->image('','80');
            $grid->column('background_maps')->image('','80');
            $grid->column('wxPlate.plate_name')->label('default');
            $grid->column('wxUser.user_name');
            // 禁用详情按钮
            $grid->disableBatchActions();
            $grid->disableActions();
        });
    }
}
